package com.xiyu.service.controller.admin.market;
import com.xiyu.service.vo.market.marketTask.MarketTaskSingleGetOutput;
import com.xiyu.service.vo.market.marketTask.MarketTaskUpdateInput;
import com.xiyu.service.vo.market.marketTask.MarketTaskCreateInput;
import com.xiyu.service.vo.market.marketTask.MarketTaskPageQueryOutput;
import com.xiyu.service.vo.market.marketTask.MarketTaskPageQueryInput;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import jakarta.validation.*;

import com.xiyu.service.framework.web.web.core.pojo.PageResult;
import com.xiyu.service.framework.web.web.core.pojo.CommonResult;
import static com.xiyu.service.framework.web.web.core.pojo.CommonResult.success;

import com.xiyu.service.framework.excel.core.util.ExcelUtils;

import com.xiyu.service.framework.operateLog.core.annotations.OperateLog;
import static com.xiyu.service.framework.operateLog.core.enums.OperateTypeEnum.*;

import com.xiyu.service.service.market.MarketTaskService;

@Tag(name = "邮件营销")
@RestController
@RequestMapping("/market/market-task")
@Validated
public class MarketTaskController {

    @Resource
    private MarketTaskService marketTaskService;

    @GetMapping("/page-query")
    @Operation(summary = "分页查询营销任务")
    public CommonResult<PageResult<MarketTaskPageQueryOutput>> pageQuery(@Valid MarketTaskPageQueryInput inputVO) {
        return success(marketTaskService.pageQuery(inputVO));
    }

    @PostMapping("/create")
    @Operation(summary = "新增营销任务")
    public CommonResult<Long> create(@Valid @RequestBody MarketTaskCreateInput inputVO) {
        return success(marketTaskService.create(inputVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新任务")
    public CommonResult<Boolean> update(@Valid @RequestBody MarketTaskUpdateInput inputVO) {
        return success(marketTaskService.update(inputVO));
    }

    @GetMapping("/single-get")
    @Operation(summary = "获取单个营销任务")
    @Parameter(name = "id", description = "邮件营销任务主键ID", example = "")
    public CommonResult<MarketTaskSingleGetOutput> singleGet(@RequestParam("id") Long id) {
        return success(marketTaskService.singleGet(id));
    }

    @DeleteMapping("/deleted")
    @Operation(summary = "删除")
    @Parameter(name = "id", description = "邮件营销任务主键ID", example = "")
    public CommonResult<Boolean> deleted(@RequestParam("id") Long id) {
        return success(marketTaskService.deleted(id));
    }

    @PostMapping("/cancel")
    @Operation(summary = "取消营销任务")
    @Parameter(name = "id", description = "邮件营销任务主键ID", example = "")
    public CommonResult<Boolean> cancel(@RequestParam("id") Long id) {
        return success(marketTaskService.cancel(id));
    }

}
